<?php
namespace app\common\service;

use think\Cache;
use think\cache\driver\Redis;
use think\Db;

class Finance
{
    public function test($year)
    {
        $list = Db::query("SELECT SUM(order_price) as p,FROM_UNIXTIME(create_time,'%m') AS mm FROM `yoshop_orders` where `pay_status` = 2 and FROM_UNIXTIME(create_time,'%Y') = $year GROUP BY mm ORDER by mm asc");
        
        $list = json_encode($list);
        $redis = new Redis();
        
        return $redis->set('finance',$list);
        
    }
    public function test2()
    {
        $list = Db::query("SELECT SUM(order_price) as p,FROM_UNIXTIME(create_time,'%m') AS mm ,FROM_UNIXTIME(create_time,'%Y') AS yy FROM `yoshop_orders` where `pay_status` = 2 GROUP BY mm ORDER by mm asc");
        
        $list = json_encode($list);
        // $redis = new Redis();
        
        // return $redis->set('finance',$list);
        return Cache::store('redis')->set('finance',$list);
        
        
    }
}
